package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import com.act.dao.IContractManagementDao;
import com.act.dao.ISaleManagementDao;
import com.act.domain.SaleManagement;
import com.act.dto.PagerDTO;
import com.act.service.api.ISaleManagementService;
import com.act.vo.PagerVo;

@Service
public class SaleManagementServiceImpl implements ISaleManagementService{
	
	@Resource
	private ISaleManagementDao saleManagementDao;

	@Override
	public void add(SaleManagement saleManagement) {
		saleManagementDao.add(saleManagement);
	}

	@Override
	public void delete(int id) {
		saleManagementDao.delete(id);
	}

	@Override
	public void update(SaleManagement saleManagement) {
		saleManagementDao.update(saleManagement);
	}

	@Override
	public PagerVo<Map> getAll(@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		List<Map> list = saleManagementDao.getAll(startIndex, endIndex);
		int totalCounts = saleManagementDao.getCounts();
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);

		return pagerVo;
	}

	@Override
	public SaleManagement getById(@Param("id")int id) {
		return saleManagementDao.getById(id);
	}
}
